home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / OpenLinux 2.3 CD.iso / live / usr / lib / rpm-2.5.5 / find-lang.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1999-08-10  |  1.3 KB  |  51 lines

  1. #!/bin/bash
  2. #findlang - automagically generate list of language specific files
  3. #for inclusion in an rpm spec file.
  4. #This does assume that the *.mo files are under .../share/locale/...
  5. #Run with no arguments gets a usage message.
  6.  
  7. #findlang is copyright (c) 1998 by W. L. Estes <wlestes@uncg.edu>
  8.  
  9. #Redistribution and use of this software are hereby permitted for any
  10. #purpose as long as this notice and the above copyright notice remain
  11. #in tact and are included with any redistribution of this file or any
  12. #work based on this file.
  13.  
  14. usage () {
  15. cat <<EOF
  16.  
  17. Usage: $0 TOP_DIR PACKAGE_NAME [prefix]
  18.  
  19. where TOP_DIR is
  20. the top of the tree containing the files to be processed--should be
  21. \$RPM_BUILD_ROOT usually. TOP_DIR gets sed'd out of the output list.
  22. PACKAGE_NAME is the %{name} of the package. This should also be
  23. the basename of the .mo files.  the output is written to
  24. PACKAGE_NAME.lang unless \$3 is given in which case output is written
  25. to \$3.
  26.  
  27. EOF
  28. exit 1
  29. }
  30.  
  31. if [ -z "$1" ] ; then usage
  32. elif [ $1 = / ] ; then echo $0: expects non-/ argument for '$1' 1>&2
  33. elif [ ! -d $1 ] ; then
  34. echo $0: $1: no such directory
  35. exit 1
  36. else TOP_DIR=$1
  37. fi
  38.  
  39. if [ -z "$2" ] ; then usage
  40. else NAME=$2
  41. fi
  42.  
  43. MO_NAME=${3:-$NAME.lang}
  44.  
  45. find $TOP_DIR -name $NAME.mo|sed '
  46. 1i\
  47. %defattr (644, root, root, 755)
  48. s:'"$TOP_DIR"'::
  49. s:\(.*/share/locale/\)\([^/_]\+\):%lang(\2) \1\2:
  50. ' > $MO_NAME
  51.